Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centralize command-line parsing #2412

Merged
merged 1 commit into from
Feb 8, 2017
Merged

Centralize command-line parsing #2412

merged 1 commit into from
Feb 8, 2017

Conversation

sethvargo
Copy link
Contributor

🔴 Early POC 🔴

This is a fairly large, but localized refactor to attempt to centralize our CLI parsing options and output. It adds a Meta struct that is aware of common information and includes functions for generating an HTTP/RPC client and the associated CLI flags. It also has logic on how to pretty-print flags, wrap to a specified line length, and more.

TODO

  • RPC Client
  • Don't print out help output on flag failure (the failure is way at the top and the help output often scrolls beyond)

/cc @slackpad for early review.

@sethvargo sethvargo self-assigned this Oct 18, 2016
name string
passStdin bool
timeout time.Duration
verbose bool
}

func (c *LockCommand) Help() string {
helpText := `
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you consider putting the intro text into the meta object as well and then you'd just return c.Meta.Help() here? If we had markdown in here we could strip it for the CLI and generate the web versions with some magic :-)

@slackpad slackpad added this to the 0.7.2 milestone Nov 18, 2016
@slackpad slackpad modified the milestones: 0.7.4, 0.7.2 Dec 14, 2016
@kyhavlov kyhavlov merged commit de1718a into master Feb 8, 2017
@slackpad
Copy link
Contributor

slackpad commented Feb 8, 2017

@kyhavlov the todo "Don't print out help output on flag failure (the failure is way at the top and the help output often scrolls beyond)" is worth keeping track of - that's actually pretty bad rn because the error is always at the top of a bunch of stuff.

@slackpad slackpad deleted the sethvargo/ux branch June 8, 2017 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants